import { defHttp } from '/@/utils/http/axios';
import { ContentTypeEnum } from '/@/enums/httpEnum';
import { useUserStore } from '/@/store/modules/user';
const userStore = useUserStore();
enum FormVO {
  getprocesslist = '/admin-api/bpm/process-instance/my-page',
  getprocess = '/admin-api/bpm/process-instance/get',
  createprocess = '/admin-api/bpm/process-instance/create',
  deleteprocess = '/admin-api/bpm/process-instance/cancel',
  gettodo = '/admin-api/bpm/task/todo-page',
  getdone = '/admin-api/bpm/task/done-page',
  GetProcessDefinitionList = '/admin-api/bpm/process-definition/list',
  GetProcessDefinitionBpmnXML = '/admin-api/bpm/process-definition/get-bpmn-xml',
  CreateProcessInstance = '/admin-api/bpm/process-instance/create',
  GetProcessInstance = '/admin-api/bpm/process-instance/get',
  GetTaskListByProcessInstanceId = '/admin-api/bpm/task/list-by-process-instance-id',
  GetActivityList = '/admin-api/bpm/activity/list',
  UpdateTaskAssignee = '/admin-api/bpm/task/update-assignee',
  ApproveTask = '/admin-api/bpm/task/approve',
  RejectTask = '/admin-api/bpm/task/reject',
  rollbackTask = '/admin-api/bpm/task/rollback',
}
// 获取用户分组分页
export const getProcessList = (params: any) => {
  // params.userId = userStore.getUserInfo.user.id;
  return defHttp.get<any>(
    { url: FormVO.getprocesslist, params },
    { withToken: true, withUserId: true },
  );
};
export const getProcess = (params: any) => {
  return defHttp.get<any>(
    { url: FormVO.getprocess, params },
    { withToken: false, withUserId: true },
  );
};
export const createProcess = (params: any) => {
  return defHttp.post<any>({ url: FormVO.createprocess, params });
};
export const deleteProcess = (params: any) => {
  return defHttp.delete<any>({
    url: FormVO.deleteprocess,
    params,
  });
};
export const getTodoList = (params: any) => {
  return defHttp.get<any>({ url: FormVO.gettodo, params });
};
export const getDoneList = (params: any) => {
  return defHttp.get<any>({ url: FormVO.getdone, params }, { withToken: true, withUserId: true });
};
export const getProcessDefinitionList = (params: any) => {
  return defHttp.get<any>(
    { url: FormVO.GetProcessDefinitionList, params },
    { withToken: false, withUserId: true },
  );
};
export const getProcessDefinitionBpmnXML = (params: any) => {
  return defHttp.get<any>(
    { url: FormVO.GetProcessDefinitionBpmnXML, params },
    { withToken: false, withUserId: true },
  );
};
export const createProcessInstance = (params: any) => {
  return defHttp.post<any>({ url: FormVO.CreateProcessInstance, params });
};
export const getProcessIns = (params: any) => {
  return defHttp.get<any>(
    { url: FormVO.GetProcessInstance, params },
    { withToken: false, withUserId: true },
  );
};
export const getTaskListByProcessInstanceId = (params: any) => {
  return defHttp.get<any>(
    { url: FormVO.GetTaskListByProcessInstanceId, params },
    { withToken: false, withUserId: true },
  );
};
export const getActivityList = (params: any) => {
  return defHttp.get<any>(
    { url: FormVO.GetActivityList, params },
    { withToken: false, withUserId: true },
  );
};
export const updateTaskAssignee = (params: any) => {
  return defHttp.put<any>({ url: FormVO.UpdateTaskAssignee, params });
};
export const approveTask = (params: any) => {
  return defHttp.put<any>({ url: FormVO.ApproveTask, params });
};
export const rejectTask = (params: any) => {
  return defHttp.put<any>({ url: FormVO.RejectTask, params });
};
export const rollbackTask = (params: any) => {
  return defHttp.post<any>({ url: FormVO.rollbackTask, params });
};
